import{ut as e}from"./B603vO-13smUKN.js";import{$ as t,Ft as n,Ht as r,_ as i,er as a,ft as o,g as s,k as c,mt as l,qt as u,v as d,vn as f}from"./CIxmKYxc4tZcJF.js";import{C as p}from"./DWlEJV-j33On0I.js";import{t as m}from"./AuTu7hII1ERTdj.js";var h=[`value`],g=c({__name:`oui-input-color`,props:t({lazy:{type:Boolean},disabled:{type:Boolean},plain:{type:Boolean}},{modelValue:{required:!0,default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(t){let c=t,g=e(`oui-input-color`),_=n(t,`modelValue`),v=f(),y=f(_.value??``),b=f();function x(e){let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/);if(!t)return e;let n=Number.parseInt(t[1]),r=Number.parseInt(t[2]),i=Number.parseInt(t[3]);return`#${((1<<24)+(n<<16)+(r<<8)+i).toString(16).slice(1)}`}let S=s(()=>C(y.value)||`#aaaaaa`);function C(e){if(e?.trim()){b.value||(b.value=document.createElement(`div`),b.value.style.display=`none`,b.value.style.position=`absolute`,b.value.style.left=`-9999px`,document.body.appendChild(b.value)),b.value.style.color=`rgba(0, 0, 0, 0.5)`;try{b.value.style.color=e.trim();let t=window.getComputedStyle(b.value).color;return g(`Computed color:`,t),!t||t===`rgba(0, 0, 0, 0)`||t===`rgba(0, 0, 0, 0.5)`||t===`transparent`?void 0:x(t)}catch(e){g(`Error parsing color:`,e)}}}function w(){_.value=C(y.value),y.value=_.value??``}function T(e){let t=e.target;y.value=t.value,w()}o(()=>{b.value&&b.value.parentNode&&b.value.parentNode.removeChild(b.value)});let E=f(!1);return r(_,e=>{E.value||(y.value=e??``)}),r(y,e=>{c.lazy||(_.value=C(e))}),(e,n)=>(l(),d(m,{modelValue:y.value,"onUpdate:modelValue":n[0]||=e=>y.value=e,lazy:!1,disabled:t.disabled,plain:t.plain,class:`oui-input-color-container`,onKeypress:p(w,[`enter`]),onBlur:n[1]||=e=>{E.value=!1,w()},onFocus:n[2]||=e=>E.value=!0},{start:u(()=>[i(`div`,{class:`oui-input-color`,style:a({"--color-value":S.value})},[i(`input`,{ref_key:`colorInput`,ref:v,value:S.value,class:`_plain`,type:`color`,tabindex:`-1`,onInput:T},null,40,h)],4)]),_:1},8,[`modelValue`,`disabled`,`plain`]))}});export{g as t};